package com.dgut.hisystem.service.impl;

import com.dgut.hisystem.entity.Doctor;
import com.dgut.hisystem.entity.Advice;
import com.dgut.hisystem.mapper.DoctorMapper;
import com.dgut.hisystem.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.List;
import java.util.UUID;

@Service
public class DoctorServiceImpl implements DoctorService {
    @Resource
    private DoctorMapper doctorMapper;
    public Doctor getDoctorId(Long id) {return doctorMapper.getDoctorId(id);}

    public Doctor getDoctorName(String name) {return doctorMapper.getDoctorName(name);}

    public void delete(Integer id){doctorMapper.delete(id);}

    public void updateRemark(Integer id,String yz_remark){doctorMapper.updateRemark(id,yz_remark);}

    public Advice selectAdviceById(Integer id) {return doctorMapper.selectAdviceById(id);}

    @Override
    public void insert(Doctor doctor) {
        long id = Math.abs(UUID.randomUUID().hashCode());
        doctor.setYs_id(id);
        if (doctor.getYs_office() == null) {
            doctor.setYs_office("东莞医院");
        }

        doctorMapper.insert(doctor);
    }

    @Override
    public void deleteByYhID(long yh_id) {
        doctorMapper.deleteByYhID(yh_id);
    }

    @Override
    public List<Doctor> getAllDoctors() {
        return doctorMapper.getAllDoctors();
    }
}
